package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.EncryptUtil;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.digitalchina.lxnsy.toolkit.TimeUtil;
import com.digitalchina.lxnsy.toolkit.Utils;
import com.digitalchina.lxnsy.xml.LocationXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：bigdata
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：白彦东
 * 创建时间：2016/10/20 10:32
 * 修改备注：
 * ================================================
 */

public class BusinessAccount {

    /**
     * 注册
     *
     * @param activity
     * @param loginName    注册名
     * @param phoneNumber  注册电话号码
     * @param password_sha 一次加密密码
     * @param verifyCode   验证码
     * @param userType     商户or个人，9是商户，10是个人
     * @param inviteCode   邀请码
     * @param handler
     */
    public static void register(Activity activity, String phoneNumber, String loginName, String password_sha,
                                String verifyCode, String userType, String inviteCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("loginName", loginName);
        params.put("password_sha", EncryptUtil.SHA1(password_sha));
        params.put("verifyCode", verifyCode);
        params.put("userType", userType);
        params.put("inviteCode", inviteCode);
        params.put("merchantName", ""); // 商户名 手机端默认空

        OkHttpUtil.post(activity, URL.URL_REGISTER, "请稍候···", params, handler, MSG.MSG_REGISTER_SUCCESS, MSG.MSG_REGISTER_FIELD);

    }

    /**
     * 用户注册加自动登陆
     *
     * @param activity
     * @param loginName    注册名
     * @param phoneNumber  注册电话号码
     * @param password_sha 一次加密密码
     * @param verifyCode   验证码
     * @param userType     商户or个人，9是商户，10是个人 , 14 是专家
     * @param inviteCode   邀请码
     * @param handler
     */
    public static void userRegisterAndLogin(Activity activity, String phoneNumber, String loginName, String password_sha,
                                            String verifyCode, String userType, String inviteCode, String openid, String accountId, String accountType, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("loginName", loginName);
        params.put("password_sha", EncryptUtil.SHA1(password_sha));
        params.put("verifyCode", verifyCode);
        params.put("userType", userType);
        params.put("inviteCode", inviteCode);
        params.put("mobileType", "1"); // 手机类型 0是IOS，1是Android
        params.put("merchantName", ""); // 商户名 手机端默认空
        params.put("loginChannel", "1"); // 需要增加APP标识 1-手机APP; 2-手机公众号; 3-PC
        params.put("openid", openid); //微信 支付宝 openid
        params.put("accountId", accountId); //用户为标识微信为unionid，支付宝是user_id
        params.put("accountType", accountType); //固定传WX或ZFB, WX（微信） ZFB （支付宝）


        OkHttpUtil.post(activity, URL.URL_USER_REGISTER_AND_LOGIN, "请稍候···", params, handler, MSG.MSG_REGISTER_AND_LOGIN_SUCCESS, MSG.MSG_REGISTER_AND_LOGIN_FIELD);

    }

    /**
     * 注册：发送验证码
     *
     * @param activity
     * @param phoneNumber
     * @param handler
     */
    public static void sendVerifyCode(Activity activity, String phoneNumber, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("sign", EncryptUtil.SHA1(Utils.reverseByArray(phoneNumber)).substring(10, 20));

        OkHttpUtil.post(activity, URL.URL_SEND_VERIFY_CODE, "请稍候...", params, handler, MSG.MSG_SEND_VERIFY_CODE_SUCCESS, MSG.MSG_SEND_VERIFY_CODE_FIELD);

    }


    /**
     * 农高会认证
     *
     * @param activity
     * @param mobilePhone
     * @param userType
     * @param userAccId
     * @param handler
     */
    public static void attachLocalData(Activity activity, String mobilePhone, String userType, String userAccId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("loginName", mobilePhone);
        params.put("mobilePhone", mobilePhone);
        params.put("userType", userType);
        params.put("userAccId", userAccId);

        OkHttpUtil.post(activity, URL.URL_ATTACH_LOCAL_DATA, "请稍候...", params, handler, MSG.MSG_ATTACH_LOCAL_DATA_SUCCESS, MSG.MSG_ATTACH_LOCAL_DATA_FIELD);

    }

    /**
     * 登录
     *
     * @param activity
     * @param loginName 用户名
     * @param p_sha     加密后的密码
     * @param handler
     */
    public static void login(Activity activity, String loginName, String p_sha, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("loginName", loginName);
        params.put("p_sha", p_sha);
        params.put("mobileType", "1"); // 手机类型 0是IOS，1是Android
        params.put("loginChannel", "1"); // 需要增加APP标识 1-手机APP; 2-手机公众号; 3-PC

        OkHttpUtil.post(activity, URL.URL_USER_LOGIN, "", params, handler, MSG.MSG_LOGIN_SUCCESS, MSG.MSG_LOGIN_FAILED);

    }


    /**
     * 忘记密码--发送验证码
     *
     * @param activity
     * @param phoneNumber 手机号
     * @param handler
     */
    public static void sendPhoneCodeUpdatePwd(Activity activity, String phoneNumber, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);

        OkHttpUtil.post(activity, URL.URL_SEND_PHONE_CODE_UPDATE_PWD, "请稍候...", params, handler, MSG.MSG_SEND_PHONE_CODE_UPDATE_PWD_SUCCESS, MSG.MSG_SEND_PHONE_CODE_UPDATE_PWD_FIELD);

    }


    /**
     * 忘记密码--校验验证码
     *
     * @param activity
     * @param phoneNumber
     * @param verifyCode
     * @param handler
     */
    public static void safeCheckForUpPwd(Activity activity, String phoneNumber, String verifyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("verifyCode", verifyCode);

        OkHttpUtil.post(activity, URL.URL_SAFE_CHECK_FOR_UP_PWD, "请稍候...", params, handler, MSG.MSG_SAFE_CHECK_FOR_UP_PWD_SUCCESS, MSG.MSG_SAFE_CHECK_FOR_UP_PWD_FIELD);

    }


    /**
     * 忘记密码--->设置新密码
     *
     * @param activity
     * @param phoneNumber
     * @param password
     * @param confirmPassword
     * @param handler
     */
    public static void setNewPwd(Activity activity, String phoneNumber, String password, String confirmPassword, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("password", password);
        params.put("shaPassword", EncryptUtil.SHA1(confirmPassword));

        OkHttpUtil.post(activity, URL.URL_SET_NEW_PWD, "请稍候...", params, handler, MSG.MSG_SET_NEW_PWD_SUCCESS, MSG.MSG_SET_NEW_PWD_FIELD);

    }

    /**
     * 修改手机号--->发送验证码
     *
     * @param activity
     * @param phoneNumber
     * @param isSend4NewPhone 修改手机号，是否为新手机发送
     * @param handler
     */
    public static void sendPhoneVerifyCode(Activity activity, String isSend4NewPhone, String phoneNumber, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("isSend4NewPhone", isSend4NewPhone);

        OkHttpUtil.post(activity, URL.URL_SEND_PHONE_VERIFY_CODE, "请稍候...", params, handler, MSG.MSG_SEND_PHONE_VERIFY_CODE_SUCCESS, MSG.MSG_SEND_PHONE_VERIFY_CODE_FIELD);

    }

    /**
     * 修改手机号--->校验旧手机验证码
     *
     * @param activity
     * @param phoneNumber
     * @param verifyCode
     * @param handler
     */
    public static void checkPhoneVerifyCode(Activity activity, String phoneNumber, String verifyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("verifyCode", verifyCode);

        OkHttpUtil.post(activity, URL.URL_CHECK_PHONE_VERIFY_CODE, "请稍候...", params, handler, MSG.MSG_CHECK_PHONE_VERIFY_CODE_SUCCESS, MSG.MSG_CHECK_PHONE_VERIFY_CODE_FIELD);

    }

    /**
     * 修改手机号--->校验新手机验证码
     *
     * @param activity
     * @param phoneNumber
     * @param verifyCode
     * @param handler
     */
    public static void checkNewPhoneVerifyCode(Activity activity, String phoneNumber, String verifyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("verifyCode", verifyCode);

        OkHttpUtil.post(activity, URL.URL_CHECK_NEW_PHONE_VERIFY_CODE, "请稍候...", params, handler, MSG.MSG_CHECK_NEW_PHONE_VERIFY_CODE_SUCCESS, MSG.MSG_CHECK_NEW_PHONE_VERIFY_CODE_FIELD);

    }

    /**
     * 修改手机号--->修改手机号码
     *
     * @param activity
     * @param phoneNumber
     * @param verifyCode
     * @param handler
     */
    public static void updateMobilePhone(Activity activity, String phoneNumber, String verifyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("useraccid", UserXML.getUserId(activity));
        params.put("phoneNumber", phoneNumber);
        params.put("verifyCode", verifyCode);

        OkHttpUtil.post(activity, URL.URL_UPDATE_MOBILE_PHONE, "请稍候...", params, handler, MSG.MSG_UPDATE_MOBILE_PHONE_SUCCESS, MSG.MSG_UPDATE_MOBILE_PHONE_FIELD);

    }

    /**
     * 修改密码
     *
     * @param activity
     * @param oldPassword
     * @param confirmPassword
     * @param handler
     */
    public static void updatePasswordOld2New(Activity activity, String oldPassword, String confirmPassword, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("useraccId", UserXML.getUserId(activity));
        params.put("oldPassword", EncryptUtil.SHA1(oldPassword));
        params.put("confirmPassword", EncryptUtil.SHA1(confirmPassword));

        OkHttpUtil.post(activity, URL.URL_UPDATE_PASSWORDOLD_2_NEW, "请稍候...", params, handler, MSG.MSG_UPDATE_PASSWORDOLD_2_NEW_SUCCESS,
                MSG.MSG_UPDATE_PASSWORDOLD_2_NEW_FIELD);

    }

    /**
     * 获取当前用户个人信息
     *
     * @param activity
     * @param handler
     * @param handler
     */
    public static void getPersonalInfoById(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_PERSONAL_INFO_BY_ID, "", params, handler, MSG.MSG_GET_PERSONAL_INFO_BY_ID_SUCCESS, MSG.MSG_GET_PERSONAL_INFO_BY_ID_FIELD);

    }

    /**
     * 获取指定用户个人信息
     *
     * @param activity
     * @param userId
     * @param handler
     */
    public static void getPersonalInfoById(Activity activity, String userId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", userId);

        OkHttpUtil.post(activity, URL.URL_GET_PERSONAL_INFO_BY_ID, "", params, handler, MSG.MSG_GET_PERSONAL_INFO_BY_ID_SUCCESS, MSG.MSG_GET_PERSONAL_INFO_BY_ID_FIELD);

    }

    /**
     * 编辑个人信息
     *
     * @param activity
     * @param params   修改对应的字段
     *                 headPortrait    头像
     *                 niceName        昵称
     *                 trueName        真实姓名
     *                 userSex         性别
     *                 userBirthday    生日
     *                 idCardNo        身份证号
     *                 userEmail       电子邮箱
     *                 hobbies         兴趣爱好  以；分割的字符串
     *                 typeCode        产业编号
     *                 dimensions      产业规模
     * @param params   修改新的参数集合
     * @param handler
     */
    public static void editPersonalBaseInfo(Activity activity, HttpParams params, Handler handler) {


        OkHttpUtil.post(activity, URL.URL_EDIT_PERSONAL_INFO_BY_ID, "", params, handler, MSG.MSG_EDIT_PERSONAL_INFO_BY_ID_SUCCESS, MSG.MSG_EDIT_PERSONAL_INFO_BY_ID_FIELD);

    }


    /**
     * 修改个人地区
     * countyCode      地区编码
     * cityCode        城市编码
     * provinceCode    省编码
     *
     * @param activity
     * @param provinceCode
     * @param cityCode
     * @param countyCode
     * @param handler
     */
    public static void editPersonalAddress(Activity activity, String provinceCode, String cityCode, String countyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("provinceCode", provinceCode);
        params.put("cityCode", cityCode);
        params.put("countyCode", countyCode);

        OkHttpUtil.post(activity, URL.URL_EDIT_PERSONAL_INFO_BY_ID, "", params, handler, MSG.MSG_EDIT_PERSONAL_INFO_BY_ID_SUCCESS, MSG.MSG_EDIT_PERSONAL_INFO_BY_ID_FIELD);

    }

    /**
     * 产业列表
     *
     * @param activity
     * @param handler
     */
    public static void getTradeTypeList(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_GET_TRADE_TYPE_LIST, "", params, handler, MSG.MSG_GET_TRADE_TYPE_SUCCESS, MSG.MSG_GET_TRADE_TYPE_FIELD);

    }

    /**
     * 用户积分列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param pointStatus 正负 0 正 1负 不传为全部
     * @param handler
     */
    public static void getCoinPointList(Activity activity, String page, String limit, String pointStatus, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("page", page);
        params.put("limit", limit);
        params.put("pointStatus", pointStatus);
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_COIN_POINT_LIST, "", params, handler, MSG.MSG_GET_COIN_POINT_LIST_SUCCESS, MSG.MSG_GET_COIN_POINT_LIST_FIELD);

    }

    /**
     * App分享回调接口
     *
     * @param activity
     * @param channel  渠道
     *                 (1-PC端;2-移动端;3-QQ;4-微信)
     * @param handler
     */
    public static void appShare(Activity activity, String itemId, String itemType, String channel, String itemName, String itemUrl, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId); // 分享资源标识
        params.put("itemType", itemType); // (1-农产品;2-资讯;3-农资;4-农事;5-视频;6-农家专访;7-app)
        params.put("actionType", "3"); // (1-浏览;2-点赞;3-分享)
        params.put("channel", channel); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", itemName);
        params.put("itemUrl", itemUrl);

        OkHttpUtil.post(activity, URL.URL_APP_SHARE, "", params, handler, MSG.MSG_APP_SHARE_SUCCESS, MSG.MSG_APP_SHARE_FIELD);
    }

    /**
     * 分享其他
     *
     * @param activity
     * @param itemId
     * @param itemType 1-农产品、2-资讯、3-农资、4-农事、5-视频、6-名家专访、7-app、8-技术大全、9-专家、10-banner网页、11-经验交流、12-标准化种植_记录农事、13-标准化种植_专家指导、14-标准化种植_新农艺、15-标准化种植_病虫草害、16-活动、17-共享三农
     * @param channel
     * @param itemName
     * @param itemUrl
     * @param handler
     */
    public static void appShareOther(Activity activity, String itemId, String itemType, String channel, String itemName, String itemUrl, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId); // 分享资源标识
        params.put("itemType", itemType); // (1-农产品;2-资讯;3-农资;4-农事;5-视频;6-农家专访;7-app)
        params.put("actionType", "3"); // (1-浏览;2-点赞;3-分享)
        params.put("channel", channel); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", itemName);
        params.put("itemUrl", itemUrl);

        OkHttpUtil.post(activity, URL.URL_APP_SHARE_OTHER, "", params, handler, MSG.MSG_APP_SHARE_SUCCESS, MSG.MSG_APP_SHARE_FIELD);
    }

    /**
     * 资源浏览统计
     *
     * @param activity
     * @param itemId
     * @param itemType 1-农产品、2-资讯、3-农资、4-农事、5-视频、6-名家专访、7-app、8-技术大全、9-专家、10-banner网页、11-经验交流、12-标准化种植_记录农事、13-标准化种植_专家指导、14-标准化种植_新农艺、15-标准化种植_病虫草害、16-活动、17-共享三农
     * @param itemName
     * @param itemUrl
     * @param handler
     */
    public static void appBrowse(Activity activity, String itemId, String itemType, String itemName, String itemUrl, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId); // 分享资源标识
        params.put("itemType", itemType); // (1-农产品;2-资讯;3-农资;4-农事;5-视频;6-农家专访;7-app)
        params.put("actionType", "1"); // (1-浏览;2-点赞;3-分享)
        params.put("channel", "2"); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", itemName);
        params.put("itemUrl", itemUrl);

        OkHttpUtil.post(activity, URL.URL_OPER_ACTION, "", params, handler, MSG.MSG_APP_SHARE_SUCCESS, MSG.MSG_APP_SHARE_FIELD);
    }

    /**
     * 点赞统计
     *
     * @param activity
     * @param itemId
     * @param itemType
     * @param itemName
     * @param itemUrl
     * @param handler
     */
    //1-农产品、2-资讯、3-农资、4-农事、5-视频、6-名家专访、7-app、8-技术大全、9-专家、10-banner网页、11-经验交流、12-标准化种植_记录农事、13-标准化种植_专家指导、14-标准化种植_新农艺、15-标准化种植_病虫草害、16-活动、17-共享三农
    //19 农业视频  20用户关注
    public static void appPraise(Activity activity, String itemId, String itemType, String itemName, String itemUrl, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId); // 分享资源标识
        params.put("itemType", itemType); // (1-农产品;2-资讯;3-农资;4-农事;5-视频;6-农家专访;7-app)
        params.put("actionType", "2"); // (1-浏览;2-点赞;3-分享;4-点击)
        params.put("channel", "2"); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", itemName);
        params.put("itemUrl", itemUrl);

        OkHttpUtil.post(activity, URL.URL_OPER_ACTION, "", params, handler, MSG.MSG_PRAISE_SUCCESS, MSG.MSG_PRAISE_FIELD);
    }
    public static void appPraiseCancel(Activity activity, String itemId, String itemType, String itemName, String itemUrl, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId); // 分享资源标识
        params.put("itemType", itemType); // (1-农产品;2-资讯;3-农资;4-农事;5-视频;6-农家专访;7-app)
        params.put("actionType", "2"); // (1-浏览;2-点赞;3-分享;4-点击)
        params.put("channel", "2"); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", itemName);
        params.put("itemUrl", itemUrl);

        OkHttpUtil.post(activity, URL.URL_OPER_CANCEL_ACTION, "", params, handler, MSG.MSG_PRAISE_CANCEL_SUCCESS, MSG.MSG_PRAISE_CANCEL_FIELD);
    }

    public static void appFollow(Activity activity, String itemId, String itemType, String itemName, String itemUrl, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId); // 分享资源标识
        params.put("itemType", itemType); // (1-农产品;2-资讯;3-农资;4-农事;5-视频;6-农家专访;7-app)
        params.put("actionType", "5"); // (1-浏览;2-点赞;3-分享;4-点击)
        params.put("channel", "2"); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", itemName);
        params.put("itemUrl", itemUrl);

        OkHttpUtil.post(activity, URL.URL_OPER_ACTION, "", params, handler, MSG.MSG_PRAISE_SUCCESS, MSG.MSG_PRAISE_FIELD);
    }
    public static void appFollowCancel(Activity activity, String itemId, String itemType, String itemName, String itemUrl, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId); // 分享资源标识
        params.put("itemType", itemType); // (1-农产品;2-资讯;3-农资;4-农事;5-视频;6-农家专访;7-app)
        params.put("actionType", "5"); // (1-浏览;2-点赞;3-分享;4-点击)
        params.put("channel", "2"); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", itemName);
        params.put("itemUrl", itemUrl);

        OkHttpUtil.post(activity, URL.URL_OPER_CANCEL_ACTION, "", params, handler, MSG.MSG_PRAISE_CANCEL_SUCCESS, MSG.MSG_PRAISE_CANCEL_FIELD);
    }

    /**
     * @param activity
     * @param itemId
     * @param itemType //1-农产品、2-资讯、3-农资、4-农事、5-视频、6-名家专访、7-app、8-技术大全、9-专家、10-banner网页、11-经验交流、12-标准化种植_记录农事、13-标准化种植_专家指导、14-标准化种植_新农艺、15-标准化种植_病虫草害、16-活动、17-共享三农
     * @param handler
     */
    public static void appOnclick(Activity activity, String itemId, String itemType, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userId", UserXML.getUserId(activity));
        params.put("itemId", itemId);
        params.put("itemType", itemType);
        params.put("actionType", "4"); // (1-浏览;2-点赞;3-分享;4-点击)
        params.put("channel", "2"); // (1-PC端;2-移动端;3-QQ;4-微信)
        params.put("itemName", "");
        params.put("itemUrl", "");

        OkHttpUtil.post(activity, URL.URL_OPER_ACTION, "", params, handler, MSG.MSG_PRAISE_SUCCESS, MSG.MSG_PRAISE_FIELD);
    }


    /**
     * 获取专家信息
     *
     * @param activity
     * @param handler
     */
    public static void toEditPersonalInfo(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("expertId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_TO_EDIT_PERSONAL_INFO, "", params, handler, MSG.MSG_TO_EDIT_PERSONAL_INFO_SUCCESS, MSG.MSG_TO_EDIT_PERSONAL_INFO_FIELD);

    }

    /**
     * 获取首页banner
     * <p>
     * 0/无需跳转
     * 1/商品详情
     * 2/农事详情
     * 3/专家详情
     * 4/视频详情
     * 5/培训详情
     * 6/专访详情
     * 7/人才需求详情
     * 8/人力供应详情
     * 9/价格列表
     * 10/商品列表
     * 11/农事列表
     * 12/专家列表
     * 13/视频列表
     * 14/培训列表
     * 15/本期名家列表
     * 16/往期名家列表
     * 17/人才需求列表
     * 18/人力供应列表
     * 19/跳转网页
     * 20/快速提问
     *
     * @param activity
     * @param handler
     */
    public static void bannerInfo(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_BANNER_INFO, "", params, handler, MSG.MSG_BANNER_INFO_SUCCESS, MSG.MSG_BANNER_INFO_FIELD);

    }


    /**
     * 验证码登录
     *
     * @param activity
     * @param phoneNumber
     * @param verifyCode
     * @param handler
     */
    public static void loginByPhone(Activity activity, String phoneNumber, String verifyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("verifyCode", verifyCode);
        params.put("sign", EncryptUtil.SHA1(Utils.reverseByArray(phoneNumber)).substring(10, 20));
        params.put("mobileType", "1"); // 手机类型 0是IOS，1是Android
        params.put("loginChannel", "1"); // 需要增加APP标识 1-手机APP; 2-手机公众号; 3-PC

        OkHttpUtil.post(activity, URL.URL_USER_LOGIN_LOGIN_BY_PHONE, "请稍候···", params, handler, MSG.MSG_LOGIN_SUCCESS, MSG.MSG_LOGIN_FAILED);

    }

    /**
     * 登录获取验证码
     *
     * @param activity
     * @param phoneNumber
     * @param handler
     */
    public static void sendLoginVerifyCode(Activity activity, String phoneNumber, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("phoneNumber", phoneNumber);
        params.put("sign", EncryptUtil.SHA1(Utils.reverseByArray(phoneNumber)).substring(10, 20));

        OkHttpUtil.post(activity, URL.URL_USER_LOGIN_CODE_SEND, "请稍候···", params, handler, MSG.MSG_USER_LOGIN_CODE_SEND_SUCCESS, MSG.MSG_USER_LOGIN_CODE_SEND_FIELD);

    }


    /**
     * 农币礼品列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void coinList(Activity activity, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_COIN_LIST, "", params, handler, MSG.MSG_COIN_LIST_SUCCESS, MSG.MSG_COIN_LIST_FIELD);

    }

    /**
     * @param activity
     * @param giftId           礼品ID
     * @param consigneeName    收货人姓名
     * @param consigneeTel     收货人电话
     * @param exchangeAmount   兑换数量
     * @param consigneeAddress 收货人地址
     * @param handler
     */
    public static void saveExchange(Activity activity, String giftId, String consigneeName, String consigneeTel, String exchangeAmount, String consigneeAddress, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("giftId", giftId);
        params.put("consigneeName", consigneeName);
        params.put("consigneeTel", consigneeTel);
        params.put("exchangeAmount", exchangeAmount);
        params.put("consigneeAddress", consigneeAddress);
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_SAVE_EXCHANGE, "请稍等...", params, handler, MSG.MSG_SAVE_EXCHANGE_SUCCESS, MSG.MSG_SAVE_EXCHANGE_FIELD);

    }

    /**
     * 我的兑换列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void myExchange(Activity activity, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_MY_EXCHANGE, "", params, handler, MSG.MSG_MY_EXCHANGE_SUCCESS, MSG.MSG_MY_EXCHANGE_FIELD);

    }

    /**
     * 单位地址
     *
     * @param activity
     * @param handler
     */
    public static void organizationList(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_ORGANIZATION_LIST, "", params, handler, MSG.MSG_ORGANIZATION_LIST_SUCCESS, MSG.MSG_ORGANIZATION_LIST_FIELD);

    }


    /**
     * 通知列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void noticeList(Activity activity, int page, int limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));

        OkHttpUtil.post(activity, URL.URL_NOTICE_LIST_V2, "", params, handler, MSG.MSG_NOTICE_LIST_SUCCESS, MSG.MSG_NOTICE_LIST_FIELD);

    }


    /**
     * 判断是否有最新消息
     *
     * @param activity
     * @param datetime
     * @param handler
     */
    public static void hotNews(Activity activity, String datetime, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("datetime", datetime);

        OkHttpUtil.post(activity, URL.URL_HOT_NEWS_V2, "", params, handler, MSG.MSG_HOT_NEWS_SUCCESS, MSG.MSG_HOT_NEWS_FIELD);

    }


    /**
     * 保存用户定位信息
     *
     * @param activity
     * @param handler
     */
    public static void saveUserLocation(Activity activity, Handler handler) {

        if (StringUtil.isStrEmpty(UserXML.getUserId(activity)))
            return;

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("locationTime", TimeUtil.getCurrentTime());
        params.put("province", LocationXML.getProvince(activity));
        params.put("city", LocationXML.getCity(activity));
        params.put("county", LocationXML.getDistrict(activity));
        params.put("address", LocationXML.getStreet(activity));

        OkHttpUtil.post(activity, URL.URL_SAVE_USER_LOCATION, "", params, handler, MSG.MSG_SAVE_USER_LOCATION_SUCCESS, MSG.MSG_SAVE_USER_LOCATION_FIELD);

    }

    public static void saveUserLocation(Activity activity, String province, String city, String county, String address, Handler handler) {

        if (StringUtil.isStrEmpty(UserXML.getUserId(activity)))
            return;

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("locationTime", TimeUtil.getCurrentTime());
        params.put("province", province);
        params.put("city", city);
        params.put("county", county);
        params.put("address", address);

        OkHttpUtil.post(activity, URL.URL_SAVE_USER_LOCATION, "", params, handler, MSG.MSG_SAVE_USER_LOCATION_SUCCESS, MSG.MSG_SAVE_USER_LOCATION_FIELD);

    }

    public static void saveUserLocationError(Activity activity, Handler handler) {

        if (StringUtil.isStrEmpty(UserXML.getUserId(activity)))
            return;

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("locationTime", TimeUtil.getCurrentTime());
        params.put("province", "");
        params.put("city", "");
        params.put("county", "");
        params.put("address", "");

        OkHttpUtil.post(activity, URL.URL_SAVE_USER_LOCATION, "", params, handler, MSG.MSG_SAVE_USER_LOCATION_SUCCESS, MSG.MSG_SAVE_USER_LOCATION_FIELD);

    }


    /**
     * 获取天气
     *
     * @param activity
     * @param handler
     */
    public static void getCityWeather(Activity activity, String city, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("city", city);

        OkHttpUtil.post(activity, URL.URL_GET_CITY_WEATHER, "", params, handler, MSG.MSG_GET_CITY_WEATHER_SUCCESS, MSG.MSG_GET_CITY_WEATHER_FIELD);

    }

    /**
     *技术大全详情
     */
    public static void getTechnologiesDetail(Activity activity,  String id, Handler handler) {
        HttpParams params = new HttpParams();
        OkHttpUtil.get(activity, URL.GET_CISTC_DETAIL+id, "", params, handler, MSG.MSG_TECHNOLOGIES_SUCCESS, MSG.MSG_TECHNOLOGIES_FIELD);

    }

    /**
     * 用户行为收集
     *
     * @param actionType （"0"代表技术大全，"1"代表专家详情，"2"代表专家咨询，"3"代表专家咨询群发）
     * @param sourceId   （技术大全的ID或者专家的ID  根据actionType的确定）
     * @param handler
     */
    public static void saveUserBehaviorByMobile(Activity activity, String actionType, String sourceId, Handler handler) {

        if (StringUtil.isStrEmpty(UserXML.getUserId(activity)))
            return;

        HttpParams params = new HttpParams();
        params.put("actionType", actionType);
        params.put("sourceId", sourceId);
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_SAVE_USER_BEHAVIOR_BY_MOBILE, "", params, handler, MSG.MSG_SAVE_USER_BEHAVIOR_BY_MOBILE_SUCCESS, MSG.MSG_SAVE_USER_BEHAVIOR_BY_MOBILE_FIELD);

    }

    /**
     * 获取个人信息
     *
     * @param activity
     * @param userAccId
     * @param handler
     */
    public static void getPersonInfoById(Activity activity, String userAccId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", userAccId);

        OkHttpUtil.post(activity, URL.URL_GET_PERSON_INFO, "", params, handler, MSG.MSG_GET_PERSON_INFO_SUCCESS, MSG.MSG_GET_PERSON_INFO_FIELD);

    }


    /**
     * 第3放账号绑定列表
     *
     * @param activity
     * @param handler
     */
    public static void get3rdUserInfo(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccid", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_3RD_USER_INFO, "加载中", params, handler, MSG.MSG_GET_3RD_USER_INFO_SUCCESS, MSG.MSG_GET_3RD_USER_INFO_FIELD);

    }


    /**
     * 第3方帐户绑定接口
     *
     * @param activity
     * @param openid      微信openid  支付宝AlipayOpenId
     * @param accountId   用户为标识微信为unionid，支付宝是user_id
     * @param accountType 固定传WX或ZFB, WX（微信） ZFB （支付宝）
     * @param handler
     */
    public static void bind3rdUserInfo(Activity activity, String openid, String accountId, String accountType,String nickname, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccid", UserXML.getUserId(activity));
        params.put("openid", openid);
        params.put("accountId", accountId);
        params.put("accountType", accountType);
        params.put("nickname", nickname);

        OkHttpUtil.post(activity, URL.URL_BIND_3RD_USER_INFO, "绑定中...", params, handler, MSG.MSG_BIND_3RD_USER_INFO_SUCCESS, MSG.MSG_BIND_3RD_USER_INFO_FIELD);

    }

    /**
     * 第三方登录
     *
     * @param activity
     * @param accountType
     * @param userId      第3方帐户唯一标识 微信为openId 支付宝为 user_id
     * @param handler
     */
    public static void loginBy3rd(Activity activity, String accountType, String userId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("accountType", accountType);
        params.put("userId", userId);
        params.put("loginChannel", "1"); // 需要增加APP标识 1-手机APP; 2-手机公众号; 3-PC
        params.put("mobileType", "1"); // 手机类型 0是IOS，1是Android


        OkHttpUtil.post(activity, URL.URL_LOGIN_BY_3RD, "登录中...", params, handler, MSG.MSG_LOGIN_BY_3RD_SUCCESS, MSG.MSG_LOGIN_BY_3RD_FIELD);

    }

    /**
     * app每天登录处理农币信息接口
     *
     * @param activity
     * @param handler
     */
    public static void getAgriCoinInfo(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("loginChannel", "1"); // 需要增加APP标识 1-手机APP; 2-手机公众号; 3-PC
        params.put("mobileType", "1"); // 手机类型 0是IOS，1是Android


        OkHttpUtil.post(activity, URL.URL_GET_AGRI_COIN_INFO, "", params, handler, MSG.MSG_GET_AGRI_COIN_INFO_SUCCESS, MSG.MSG_GET_AGRI_COIN_INFO_FIELD);

    }

    /**
     * 获取最新版本号
     *
     * @param activity
     * @param handler
     */
    public static void getNewVersion(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();


        OkHttpUtil.post(activity, URL.URL_GET_APK_UPDATE_URL, "正在检测...", params, handler, MSG.MSG_GET_APK_UPDATE_SUCCESS, MSG.MSG_GET_APK_UPDATE_FIELD);

    }

    /**
     * 用户权限判断 1  有权限 0   没有权限
     *
     * @param activity
     * @param handler
     */
    public static void checkUserPermission(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_CHECK_USER_PERMISSION, "", params, handler, MSG.MSG_CHECK_USER_PERMISSON_SUCCESS, MSG.MSG_CHECK_USER_PERMISSON_FIELD);

    }

    /**
     * 我管理的企业列表
     *
     * @param activity
     * @param handler
     */
    public static void getAllEnterprise(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_ALL_ENTERPRISE, "", params, handler, MSG.MSG_GET_ALL_ENTERPRISE_SUCCESS, MSG.MSG_GET_ALL_ENTERPRISE_FIELD);

    }
}
